home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / masm.arc / CHDIR.ASM < prev    next >
Assembly Source File  |  1985-03-06  |  2KB  |  47 lines

  1.         TITLE CHDIR - DOS 2.0 Change Directory Function
  2. ;       BASCOM Callable subroutine to invoke CHDIR function from DOS
  3. ;              From an idea by Jim Button:
  4. ;       Written By    John Chapman       CompuServ [70205,1217]
  5. ;       Version 1.1   January 1984
  6. ;INVOCATION:   This procedure is called as follows:
  7. ;           CALL CHDIR(DIRSTR$,RETCODE%)
  8. ;        DIRSTR$ is a string WHICH MUST BE BUILT BY CONCATENATION !!
  9. ;           (DIRSTR$ = "NEWDIR" + CHR$(0) - for example) Creation of the
  10. ;           the string by CONCAT moves the string to string space, and the    
  11. ;           REQUIRED CHR$(0) at the end produces an ASCIIZ string of the 
  12. ;           format required by the DOS service.  RETCODE% will be set to 
  13. ;           the DOS return code provided by INT 21 FC=3B as described in
  14. ;           the DOS 2.0 manual, or the DOS 2.1 Techical Reference
  15. ;
  16. ; It is suggested that the routine calling the service perform some simple    
  17. ; edit and validity checking on the directory name, if input/variable data
  18. ; is used.
  19. ;
  20. CONST   SEGMENT WORD PUBLIC 'CONST'
  21. CONST   ENDS
  22. DATA    SEGMENT WORD PUBLIC 'DATA'
  23. DATA    ENDS
  24. DGROUP  GROUP  DATA,CONST
  25. CODE    SEGMENT BYTE PUBLIC 'CODE'
  26.         PUBLIC  CHDIR
  27.         ASSUME  CS:CODE,DS:DGROUP
  28. CHDIR   PROC    FAR             ; (NO PARAMETERS)
  29.         PUSH    BP              ; SAVE ENVIRONMENT
  30.         MOV     BP,SP           ; POINT TO PARM LIST IN STACK SPACE
  31.         MOV     SI,[BP]+8       ; ==> TO STRING DESCRIPTOR (PARM 1)
  32.         MOV     DX,2[SI]        ; ACTUAL ADDR OF STRING VARIABLE 
  33.         MOV     AH,3BH          ; SETUP FOR DOS CALL 3B
  34.         INT     21H             ; DOS CALL
  35.         JC      RC_SAVE         ; PASS RETURN CODE IF THERE (CARRY FLAG SET)
  36.         XOR     AX,AX           ; CLEAR AX (rc=0) IF CARRY FLAG NOT SET
  37. RC_SAVE:
  38.         MOV     SI,[BP]+6       ; POINT TO SECOND PARAMETER
  39.         MOV     [SI],AX         ; STORE RETURN CODE IN SECOND PARAMETER
  40.         POP     BP              ; RESTORE ENVIRONMENT
  41.         RET     4
  42. TAGIT   DB      "$$$CHDIR$$$"
  43. CHDIR   ENDP
  44. CODE    ENDS
  45.         END
  46.